Skip to content

Skip walking into param-env component if it has no placeholder/re-var #143500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2025

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Jul 5, 2025

Although it only provides a minor perf improvement, it seems like it could matter in more pathological cases.

@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jul 5, 2025
@compiler-errors
Copy link
Member Author

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jul 5, 2025

⌛ Trying commit e13757e with merge e3ecd5f

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jul 5, 2025
[perf] Skip walking into param-env component if it has no placeholder/re-var
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 5, 2025
@rust-bors
Copy link

rust-bors bot commented Jul 5, 2025

☀️ Try build successful (CI)
Build commit: e3ecd5f (e3ecd5f5fd02f50bc278c1f0cd5b4dbd9e07242a, parent: 6dec76f1c2809fded082dd44d3752d3f6220d767)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e3ecd5f): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.0% [0.0%, 0.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.5% [-0.5%, -0.5%] 3
All ❌✅ (primary) - - 0

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

Results (secondary 0.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.4% [2.4%, 2.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.0% [-2.0%, -2.0%] 1
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 461.008s -> 461.232s (0.05%)
Artifact size: 372.14 MiB -> 372.18 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 5, 2025
@compiler-errors compiler-errors changed the title [perf] Skip walking into param-env component if it has no placeholder/re-var Skip walking into param-env component if it has no placeholder/re-var Jul 6, 2025
@compiler-errors
Copy link
Member Author

r? lcnr

@compiler-errors compiler-errors marked this pull request as ready for review July 6, 2025 17:18
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 6, 2025
@@ -1069,8 +1070,10 @@ where
} else {
ControlFlow::Continue(())
}
} else {
} else if ty.has_type_flags(TypeFlags::HAS_PLACEHOLDER | TypeFlags::HAS_RE_INFER) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why only RE_INFER instead of full infer?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bc we only care about infer regions in this folder's logic -- it would not even be necessary if we didn't replace free regions with infer

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would we care about ty/ct infer for this folder anyways? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we only care as in: there should never be infer types/consts in the param_env 😁 if we end up with a ty var for whatever reason, then this folder would start incorrectly treating (): Trait<?x> as global evne though it shouldn't be. It currently detects ambiguous aliases in the env as global

Copy link
Member Author

@compiler-errors compiler-errors Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how that is the case and how this behavior would change with this fast path, given that visit_ty does not care about infer types at all and because structurally_normalize_ty just returns Ok(_) for infer types.

Can you explain in more detail, because I am obviously missing something here?

Copy link
Contributor

@lcnr lcnr Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you've got u32: Trait<AmbiguousAlias>, structurally normalizing that alias results in Ok(_).

At this point we return ControlFlow::Continue(()), treating this where-bound as global. The fast path doesn't matter here 🤔 I generally feel like the way we're handling ambiguous aliases/ty infer vars here isn't right.

I can't really think of an example where this matters. HAving a TAIT in the where-clauses makes it possible to encounter this in theory, but I can't think of a program where this is matters.

I guess 🤷

@lcnr lcnr added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 11, 2025
@compiler-errors compiler-errors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 11, 2025
@lcnr
Copy link
Contributor

lcnr commented Jul 25, 2025

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 25, 2025

📌 Commit e13757e has been approved by lcnr

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 25, 2025
@bors
Copy link
Collaborator

bors commented Jul 26, 2025

⌛ Testing commit e13757e with merge ce5fdd7...

@bors
Copy link
Collaborator

bors commented Jul 26, 2025

☀️ Test successful - checks-actions
Approved by: lcnr
Pushing ce5fdd7 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 26, 2025
@bors bors merged commit ce5fdd7 into rust-lang:master Jul 26, 2025
12 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Jul 26, 2025
Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 133798f (parent) -> ce5fdd7 (this PR)

Test differences

Show 8 test diffs

8 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard ce5fdd7d42aba9a2925692e11af2bd39cf37798a --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. x86_64-apple-1: 6290.1s -> 7734.4s (23.0%)
  2. dist-x86_64-apple: 9145.1s -> 7364.4s (-19.5%)
  3. dist-apple-various: 6846.8s -> 5803.0s (-15.2%)
  4. pr-check-2: 2710.7s -> 2445.1s (-9.8%)
  5. arm-android: 6632.2s -> 6062.0s (-8.6%)
  6. aarch64-gnu-debug: 4480.1s -> 4147.5s (-7.4%)
  7. x86_64-gnu-llvm-19-3: 7184.3s -> 6669.5s (-7.2%)
  8. x86_64-gnu-llvm-19: 2948.1s -> 2737.3s (-7.2%)
  9. x86_64-rust-for-linux: 3051.6s -> 2837.7s (-7.0%)
  10. aarch64-gnu-llvm-19-1: 3759.8s -> 3518.1s (-6.4%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ce5fdd7): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.6% [-0.6%, -0.5%] 3
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -3.2%, secondary -1.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.0% [1.0%, 1.0%] 1
Improvements ✅
(primary)
-3.2% [-3.2%, -3.2%] 1
Improvements ✅
(secondary)
-3.0% [-3.0%, -3.0%] 1
All ❌✅ (primary) -3.2% [-3.2%, -3.2%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 466.195s -> 466.456s (0.06%)
Artifact size: 376.61 MiB -> 376.58 MiB (-0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants